package com.trex.modules.tbl.dw.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.trex.modules.tbl.dw.entity.TblDwPro;
import com.trex.modules.tbl.dw.service.TblDwProService;

/**
 * 电文头属性配置表Controller
 * @author jy
 * @version 2023-02-25
 */
@Controller
@RequestMapping(value = "${adminPath}/tbl/dw/tblDwPro")
public class TblDwProController extends BaseController {

	@Autowired
	private TblDwProService tblDwProService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public TblDwPro get(String recId, boolean isNewRecord) {
		return null;
	}
	
	/**
	 * 查询列表
	 */

	@RequestMapping(value = {"list", ""})
	public String list(TblDwPro tblDwPro, Model model) {
		model.addAttribute("tblDwPro", tblDwPro);
		return "modules/tbl/dw/tblDwProList";
	}
	
	/**
	 * 查询列表数据
	 */

	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<TblDwPro> listData(TblDwPro tblDwPro, HttpServletRequest request, HttpServletResponse response) {

		Page<TblDwPro> page = tblDwProService.findPage(tblDwPro);
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	//@RequiresPermissions("tbl:dw:tblDwPro:view")
	@RequestMapping(value = "form")
	public String form(TblDwPro tblDwPro, Model model) {
		model.addAttribute("tblDwPro", tblDwPro);
		return "modules/tbl/dw/tblDwProForm";
	}

	/**
	 * 保存数据
	 */
	//@RequiresPermissions("tbl:dw:tblDwPro:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated TblDwPro tblDwPro) {
		tblDwProService.save(tblDwPro);
		return renderResult(Global.TRUE, text("保存电文头属性配置表成功！"));
	}
	
	/**
	 * 删除数据
	 */
	//@RequiresPermissions("tbl:dw:tblDwPro:edit")
	@RequestMapping(value = "delete")
	@ResponseBody
	public String delete(TblDwPro tblDwPro) {
		tblDwProService.delete(tblDwPro);
		return renderResult(Global.TRUE, text("删除电文头属性配置表成功！"));
	}
	
}